<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page contentType="text/html;charset=utf-8" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%> 
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>CGPorject</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<LINK href="../styles/sciencee.css"  type=text/css rel=stylesheet>
	<LINK href="styles/stylewang.css"  type=text/css rel=stylesheet>
	<script language=javascript>
		function selall(){
			var selectAll=document.getElementById("selectAll");
			var inputs=document.getElementsByTagName("input");
			for(var i=0;i<inputs.length;i++){
				if(inputs[i].getAttribute("type")=="checkbox"){
					inputs[i].checked=selectAll.checked;
				}
			}
		}
		
		function deletemsg(){
			var selects=document.getElementsByName("select");
			var ids="";
			for(var i=0;i<selects.length;i++){
				if(selects[i].checked==true){
					ids+=selects[i].getAttribute("id")+",";
				}
			}
			var form1=document.getElementById("form1");
			var hidden=document.getElementById("ids");
			hidden.value=ids;
			form1.submit();
		}
		function showmessage(id){
			window.open("<%=path%>"+"/message/showmessage.do?id="+id,"showMessage",'top=150,left=150,scrollbars=yes,dialog=yes,modal=yes,width=570,height=445,resizable=no');
		}
		function refreshMessage(){
			window.location.href="<%=path%>/message/index.do";
			titleTip();
		}
		function messageReply(sender){
			window.open("<%=path %>/message/send.jsp?receiver="+sender,"send","top=150,left=150,scrollbars=yes,dialog=yes,modal=yes,width=590,height=455,resizable=no");
		}
		
		var title="CGProject";
		var counter=0;
		function titleTip(){
			var bs=document.getElementsByTagName("b");
			if(bs.length>3){
				flashTitle('<bean:message key="newMessage"/>');
			}else{
				top.document.title = title;
			}
		}

		function flashTitle(message){
			if(counter==2){
				counter=0;
			}
			top.document.title = counter==1 ? "【"+message+"】 - "+ title : "                " + title;
			counter++;
		}
	</script>
    
  </head>
  
  <body onLoad="window.setInterval('refreshMessage()',120000);window.setInterval('titleTip()',1500);" >
  <form id="form1" action="<%=path %>/message/delete.do?ids2=1" method="GET">
    <table  border="1" cellspacing="0" cellpadding="0">
    	<tr>
   		  <td valign="baseline"  id="btleftbian">
   		  	<b><bean:message key="selectall"/></b>
	      <input id="selectAll" type="checkbox" onClick="selall();"></td>
    	
    		<td width="50"  id="btcenterbian"><b>
   		  <bean:message key="message.sender"/></b></td>
    		<td  id="btcenterbian" width="60"><b><bean:message key="message.title"/></b></td>
    	</tr>
    	<%
    		ArrayList messagelist=(ArrayList)request.getAttribute("messagelist");
    		HashMap map;
    		for(Iterator iter=messagelist.iterator();iter.hasNext();){
    			map=(HashMap)iter.next();
    			if(map.get("isRead").equals(0)){
    	%>
    	<tr>
    		<td id="leftcenter"><input id="<%=map.get("id") %>" name="select" type="checkbox" ></td>
    		<td id="leftcenter"><%=map.get("sender") %></td>
    		<td id="leftcenter"><a href="javascript:showmessage('<%=map.get("id") %>');" style="cursor:hand"><b><%=map.get("title") %></b></a></td>
    	</tr>
    	<%}else{ %>
    	<tr>
    		<td id="leftcenter"><input id="<%=map.get("id") %>" name="select" type="checkbox" ></td>
    		<td id="leftcenter"><%=map.get("sender") %></td>
    		<td id="leftcenter"><a href="javascript:showmessage('<%=map.get("id") %>');" style="cursor:hand"><%=map.get("title") %></a></td>
    	</tr>
		
    	<%}} %>
    </table>
    

    <input name="button" type="button" onClick="window.open('<%=path %>/message/send.jsp','send','top=150,left=150,scrollbars=yes,dialog=yes,modal=yes,width=590,height=455,resizable=no')" value='<bean:message key="message.sendmessage"/>'>
    <input id="ids" type="hidden" name="ids" value="">
<input type="button" value="<bean:message key='delete'/>" onClick="if(confirm('<bean:message key="confirmdel"/>')){deletemsg();}">
  </form>
  </body>
</html>
